<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>编辑<if condition="$sw eq 1">商务跟进</if>项目-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text"><if condition="$sw eq 1">商务跟进</if>项目 > 编辑<if condition="$sw eq 1">商务跟进</if>项目</div>
	</div>
	<div id="content">
		<form action="__APP__/Project/project_edit" method="post" />
			<input type="hidden" name="action" value="edit">
			<input type="hidden" name="id" value="{$result['id']}">
			<input type="hidden" name="keyword_s" value="{$keyword_s}">
			<input type="hidden" name="center_id_s" value="{$center_id_s}">
			<input type="hidden" name="project_num_s" value="{$project_num_s}">
			<input type="hidden" name="project_name_s" value="{$project_name_s}">
			<input type="hidden" name="manager_uid_s" value="{$manager_uid_s}">
			<input type="hidden" name="director_uid_s" value="{$director_uid_s}">
			<input type="hidden" name="contract_file_s" value="{$contract_file_s}">
			<input type="hidden" name="status_id_s" value="{$status_id_s}">
			<input type="hidden" name="stage" value="{$stage}">
			<input type="hidden" name="sw" value="{$sw}">
			<input type="hidden" name="dept_id_s" value="{$dept_id_s}">
			<div class="form-main">
				<div class="form-title">编辑<if condition="$sw eq 1">商务跟进</if>项目</div>
				<div class="form-item">
					<div class="input-label">所属中心</div>
					<div class="input-item">
						{:get_center_name($result['center_id'])}
						<input type="hidden" name="center_id" class="project_type" value="{$result['center_id']}">
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>项目编号</div>
					<div class="input-item">
						<input type="text" name="project_num1" value="{$result['project_num']|substr=0,2}" class="form-control mr5" style="width:40px;" readonly autocomplete="off">
						<input type="text" name="project_num2" value="{$result['project_num']|substr=2,4}" class="form-control" style="width:46px;" maxval="{$project_max_number}" maxlength="4" autocomplete="off">
						<span class='error-item'>必填项</span>
						<span class='error-item'>必须是4位数字</span>
						<span class='error-item'>不能大于<span class="project_max_number">{$project_max_number}</span></span>
						<span class='error-item'>不能为0000</span>
						-
						<input type="text" name="project_num3" value="{$result['project_num']|substr=7,2}" class="form-control" style="width:36px;" maxlength="2" autocomplete="off">
						<span class='error-item'>必须是2位字符</span>
					</div>
				</div>
				<if condition="$sw neq 1">
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>项目名称</div>
					<div class="input-item" style="position:relative;">
						<input type="text" name="project_name" value="{$result['project_name']}" class="form-control required-text w500 project_add_inp" autocomplete="off" placeholder="省+市+项目简称+方案名称">
						<span class="error-item">必填项</span>
						<div class="project_add_search">
							<ul></ul>
						</div>
					</div>
				</div>
				</if>
				<if condition="$sw eq 1">
					<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>关联市场信息</div>
						<div class="input-item">
							<select name="info_id" class="form-control required-selted" autocomplete="off">
								<option value="-10" selected>请选择</option>
								<foreach name="info" item="vo">
									<option value="{$vo['id']}" <if condition="$result['info_id'] eq $vo['id']">selected</if>><if condition="$vo['jc_id'] neq NULL">[JC]</if>[{$vo['customer_num']}]{$vo['customer_name']}</option>
								</foreach>
							</select>
							<span class="error-item">必填项</span>
						</div>
					</div>
				</if>
				<if condition="($sw neq 1) and ($result['center_id'] neq 130004)">
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>所属部门</div>
					<div class="input-item">
						<select name="dept_id" class="form-control required-selted" disabled="true" autocomplete="off">
							<option value="-10" selected>请选择</option>
							<foreach name="dept_list" item="vo">
								<option value="{$vo['id']}" <if condition="$result['dept_id'] eq $vo['id']">selected</if>>{$vo['first_name']}</option>
							</foreach>
						</select>
						<span class="error-item">必填项</span>
					</div>
				</div>
				</if>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>项目关键字</div>
					<div class="input-item">
						<input type="text" name="key_word" value="{$result['key_word']}" class="form-control required-text w200" autocomplete="off" placeholder="最多输入6个字" maxlength="6">
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span><if condition="$result['center_id'] eq 130005">项目负责人<else/>项目经理</if></div>
					<div class="input-item">
						<select name="manager_uid" class="form-control required-selted" autocomplete="off">
							<option value="-10" selected>请选择</option>
							<foreach name="user_list" item="vo">
								<option value="{$vo['id']}" <if condition="$result['manager_uid'] eq $vo['id']">selected</if>>{$vo['username']}</option>
							</foreach>
						</select>
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span><if condition="$result['center_id'] eq 130005">项目群负责人<else/>项目总监</if></div>
					<div class="input-item">
						<select name="director_uid" class="form-control required-selted" autocomplete="off">
							<option value="-10" selected>请选择</option>
							<foreach name="user_list" item="vo">
								<option value="{$vo['id']}" <if condition="$result['director_uid'] eq $vo['id']">selected</if>>{$vo['username']}</option>
							</foreach>
						</select>
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>启动日期</div>
					<div class="input-item">
						<input type="text" name="start_date" value="{$result['start_date']}" class="form-control Wdate w100 required-text" onclick="WdatePicker()" autocomplete="off">
						<if condition="($sw neq 1) and ($result['center_id'] neq 130004)">
						至 
						<input type="text" name="end_date" value="{$result['project_end_date']}" class="form-control Wdate w100 required-text" onclick="WdatePicker({isShowClear:true})" autocomplete="off">
						<span class="error-item">必填项</span>
						<span class="input-prompt"><i class="glyphicon glyphicon-exclamation-sign ml10"></i> 结束日期</span>
						</if>
					</div>
				</div>
				<!--<if condition="(get_permission('XM',NULL,2)) or (get_permission('XM',NULL,1)) or (get_permission('SW',NULL,2)) or (get_permission('SW',NULL,1))">
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>添加人</div>
					<div class="input-item">
						<select name="add_uid" class="form-control required-selted" disabled="true" autocomplete="off">
							<option value="-10" selected>请选择</option>
							<foreach name="user_list" item="vo">
								<option value="{$vo['id']}" <if condition="$result['add_uid'] eq $vo['id']">selected</if>>{$vo['username']}</option>
							</foreach>
						</select>
						<span class="error-item">必填项</span>
					</div>
				</div>
				</if>-->
			</div>
			<div class="form-btn-item"><button class="btn btn-submit" type="submit">提交</button><button class="btn btn-default goback" type="button">返回</button></div>
		</form>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function() {
	$("[name='project_name']").focus(function(){
		$('.project_add_search').show();
	})
	$("[name='project_name']").blur(function(){
		$('.project_add_search').hide();
	})
	$("[name='project_name']").bind('propertychange input', function () {
		var val = $(this).val(),
			center_id = $("[name='center_id']").val();
		if(val!=''){
			$(this).addClass('active');
			$('.project_add_search ul').show()
			$.ajax({
				type:"POST",
				asnyc:false,
				dataType:"json",
				data:{"val":val,"center_id":center_id},
				url:"__APP__/Project/project_name",
				success:function(data){
					if(data){
						var html='';
						for(var i=0;i<data.length;i++){
							html+= "<li>"+data[i].project_name+"</li>"
						}
						$('.project_add_search ul').html(html);
					}else{
						$('.project_add_search ul').html("<li>没有匹配项目</li>");
					}
				}
			});
		}else{
			$(this).removeClass('active');
			$('.project_add_search ul').hide().html("");
		}
	})
	//表单验证
	$(".btn-submit").click(function(e){
		var tag = false;
		$(".required-text").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = true;
			}
		});
		$(".required-selted").each(function(){
			if($(this).val()==-10){
				$(this).nextAll(".error-item").eq(0).show();
				tag = true;
			}
		});
		//项目编号
		$("[name='project_num2']").each(function(){
			var $val = $(this).val(),
				$max = $(this).attr("maxval");
			
			if($val==""){
				$(this).next(".error-item").show();
				tag = true;
			}else if(!/\d{4}/.test($val)){
				$(this).nextAll(".error-item").eq(1).show();
				tag = true;
			}else if($val-0 > $max-0){
				$(this).nextAll(".error-item").eq(2).show();
				tag = true;
			}
		});
		$("[name='project_num3']").each(function(){
			var $val = $(this).val();
			
			if($val!="" && !/[a-zA-Z0-9]{2}/.test($val)){
				$(this).next(".error-item").show();
				tag = true;
			}
		});
		
		if(tag){
			return false;
		}
	});
	
	//隐藏错误提示
	$(".required-text,[name='project_num2'],[name='project_num3']").focus(function(){
		$(this).nextAll(".error-item").hide();
	});
	$(".required-selted").change(function(){
		$(this).nextAll(".error-item").hide();
	});
});
</script>
</body>
</html>